import Taro, { Component } from '@tarojs/taro'
import { View, Button, Textarea } from '@tarojs/components'

import './index.scss'

class SelfReply extends Component{
  state = {
    textVal: ''
  }
  handleModalBtnCancle(){
    this.props.onHideReplyModal()
  }
  handleModalBtnOk(){
    if(this.state.textVal){
      this.props.onReplyTextOk(this.state.textVal)
    }else{
      Taro.showToast({title: '请输入评论内容', icon: 'none'})
    }
  }
  handleTextArea(e){
    this.setState({
      textVal: e.target.value
    })
  }
  render(){
    return(
      <View className='reply-modal'>
        <Textarea onInput={this.handleTextArea.bind(this)} className='reply-modal-area' placeholder='请输入回复内容' />
        <View className='reply-modal-btngroup'>
          <Button onClick={this.handleModalBtnOk.bind(this)} className='reply-modal-btn'>确定</Button>
          <Button onClick={this.handleModalBtnCancle.bind(this)} className='reply-modal-btn'>取消</Button>
        </View>
      </View>
    )
  }
}

export default SelfReply